<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateGoodsTable extends Migration
{
    private $table = 'goods';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 255)->comment('商品名称');
            $table->string('image', 255)->comment('商品图片');
            $table->text('description')->comment('商品描述');
            $table->string('item_id', 255)->comment('商品对应游戏道具id');
            $table->double('cost_money')->default(0)->comment('支付价格');
            $table->double('cost_coin')->default(0)->comment('金币价格');
            $table->double('cost_diamond')->default(0)->comment('钻石价格');
            $table->unsignedInteger('category_id')->default(0)->comment('目录id');
            $table->tinyInteger('status')->default(1)->comment('商品状态 0.下架 1.上架');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '商品表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
